﻿package com.map 
{
	import com.element.Clips;
	import com.event.EventZheng;
	import com.IFactory;
	import com.staticInfo.EventConst;
	import com.utils.TransformCoordinate;
	import flash.display.Sprite;
	import flash.geom.Point;
	
	/**
	 * ...
	 * @author zhengzihua
	 */
	public class ShowObjectContain extends Sprite
	{
		private var objectArr:Array;//存储在该容器中的物体
		private var setObjSpace:IMap;
		public function ShowObjectContain() 
		{
			objectArr = [];
			setObjSpace = IFactory.getMap();
			addEventListener(EventConst.EVENT_ARRIVETARGET, setObjIndex);
		}
		public function addObj(obj:*):void {
			objectArr.push(obj);
			addChild(obj);
			setObjSpace.setObjectIndex(objectArr,this);
		}
		public function putElement(tp:Point,row:int,cols:int,clip:Clips):void {
			var cp:Point = TransformCoordinate.transformCoor(tp);
			clip.sx = tp.x;
			clip.sy = tp.y;
			clip.x = cp.x;
			clip.y = cp.y;
			clip.row = row;
			clip.cols = cols;
			addObj(clip);
		}
		public function delObj(level:int):void {
			removeChildAt(level);
			objectArr.splice(level, 1);
			setObjSpace.setObjectIndex(objectArr,this);
		}
		private function setObjIndex(e:EventZheng):void {
			setObjSpace.setObjectIndex(objectArr,this)
		}
		
	}
	
}